package cn.iocoder.yudao.module.wecom.convert.dept;

import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.wecom.controller.admin.dept.vo.WeDeptRespVO;
import cn.iocoder.yudao.module.wecom.dal.dataobject.dept.WeDeptDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface DeptConverter {
    DeptConverter INSTANCE = Mappers.getMapper(DeptConverter.class);

    default WeDeptRespVO convert2(WeDeptDO weDeptDO) {
        WeDeptRespVO respVO = BeanUtils.toBean(weDeptDO, WeDeptRespVO.class);
        respVO.setId(weDeptDO.getWeDeptId());
        respVO.setName(weDeptDO.getWeDeptName());
        return respVO;
    }

    default List<WeDeptRespVO> convert1(List<WeDeptDO> pageResult) {
        return CollectionUtils.convertList(pageResult, this::convert2);
    }
}
